package com.xnyzc.lhy.mis.mapper.vehicle;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xnyzc.lhy.mis.entity.result.cms.veh.VehicleManageInfo;
import com.xnyzc.lhy.mis.entity.result.vehicle.VehicleBrand;
import com.xnyzc.lhy.mis.entity.vehicle.OaSysVehicleMdict;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 车辆品牌-车系多级字典表 Mapper 接口
 * </p>
 *
 * @author lhy@xnyzc.com
 * @since 2019-07-18
 */
public interface OaSysVehicleMdictMapper extends BaseMapper<OaSysVehicleMdict> {

    @Select("<script>" +
            "SELECT    " +
            "oa_sys_vehicle_mdict.mdict_id," +
            "oa_sys_vehicle_mdict.parent_id," +
            "oa_sys_vehicle_mdict.name," +
            "oa_sys_vehicle_mdict.code," +
            "oa_sys_vehicle_mdict.veh_seats_number," +
            "oa_sys_vehicle_mdict.vehicle_type," +
            "oa_sys_vehicle_mdict.is_relation," +
            "      oa_sys_dict.label       " +
            "FROM  " +
            "oa_sys_vehicle_mdict,oa_sys_dict      " +
            "WHERE   " +
            "     oa_sys_vehicle_mdict.deleted = 0  " +
            "     AND  oa_sys_dict.deleted = 0  " +
            "AND  oa_sys_dict.type = 'require_level'   " +
            "AND  oa_sys_vehicle_mdict.vehicle_type = oa_sys_dict.value   " +
            "AND  oa_sys_vehicle_mdict.parent_id != 0   " +
            "AND  oa_sys_vehicle_mdict.expand1 = 3      " +
            "<if test='is_relation.length() !=0 '>" +
            "AND oa_sys_vehicle_mdict.is_relation = #{is_relation}  " +
            "</if>" +
            "<if test='vehicle_type.length() !=0 '>" +
            "   AND oa_sys_vehicle_mdict.vehicle_type = #{vehicle_type}  " +
            "</if>" +
            "<if test='code.size() !=0 '>" +
            "   AND oa_sys_vehicle_mdict.code IN  " +
            "<foreach collection='code' item='item'  index='index' open='(' separator=',' close=')'>" +
            "#{item}   " +
            "</foreach>   " +
            "</if>" +
            "</script>")
    List<VehicleManageInfo> getAssociatedBrandList(
            IPage iPage,
            @Param("is_relation") String isRelation,
            @Param("vehicle_type") String vehicleType,
            @Param("code") List<String> code
    );

    List<OaSysVehicleMdict> getVehicleBrand(@Param("brandName") String brandName);

    List<OaSysVehicleMdict> getVehicleSeriesOfList(@Param("brandId") String brandId,@Param("seriesName") String seriesName);
}
